<?php

namespace App\Console\Commands;

use App\UserWhiteList;
use Illuminate\Console\Command;

class UserWhiteListCommand extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'user:white';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
       $mobiles= UserWhiteList::all()->pluck('mobile');
       foreach ($mobiles as $mobile){
          $customers= \App\Customer::whereMobile($mobile)->get();
          if ($customers->isEmpty()){
              continue;
          }
          foreach ($customers as $customer){
              /**
               * @var  \App\Customer $customer
               */
              $customer->is_lock=1;
              $customer->save();
              $this->info($customer->customer_id);
          }
       }
    }
}
